#define THIS_FILE "occuper.sqf"
#include <base\tmf_constants.h>
#include <base\tmf_macros.h>
WAITINIT(occuper);

// ["Land_Cargo_House_V1_F","marker2"] execVM "occuper.sqf";
if (!isServer) exitWith {};
private ["_type","_marker","_shared_var","_taken_msg","_lost_msg","_hold_time","_marker_size","_zone_size","_error","_obj_params","_obj_params"];
DEFAULT_PARAM(_type,0,"");
DEFAULT_PARAM(_marker,1,"");
DEFAULT_PARAM(_shared_var,2,"");
DEFAULT_PARAM(_taken_msg,3,ARR_2("STR_MF_TAKENOVER",(ARR_1(_type) call CFUNC(displayName))));
DEFAULT_PARAM(_lost_msg,4,ARR_2("STR_MF_TAKENBACK",(ARR_1(_type) call CFUNC(displayName))));
DEFAULT_PARAM(_hold_time,5,30);

_error = false;
if (IS_STRING(_type)) then { _error = (_type == "") };
if (IS_STRING(_marker)) then { _error = (_marker == "") };
if (_error) exitWith {};

_obj_params = [];
_obj_params set [TMF_VEH_PARAMS_TYPE, _type];
_obj_params set [TMF_VEH_PARAMS_POS, _marker];

_zone_size = 30;

if (IS_STRING(_taken_msg)) then { _taken_msg = [_taken_msg] };
if (IS_STRING(_lost_msg)) then { _lost_msg = [_lost_msg] };

if (IS_STRING(_marker)) then {
	if (IS_MARKER(_marker)) then {
		_marker_size = ((markersize _marker) select 0) max ((markersize _marker) select 1);
		if (_marker_size > 1) then { _zone_size = _marker_size };
	};
};
_tmf_params = [];
_tmf_params = [_tmf_params,"ZONE_SIZE",_zone_size] call CFUNC(hashSet);
_tmf_params = [_tmf_params,"TAKEN_MSG",_taken_msg] call CFUNC(hashSet);
_tmf_params = [_tmf_params,"LOST_MSG",_lost_msg] call CFUNC(hashSet);
_tmf_params = [_tmf_params,"SHARED_VAR",_shared_var] call CFUNC(hashSet);
_tmf_params = [_tmf_params,"HOLD_TIME",_hold_time] call CFUNC(hashSet);
// _tmf_params = [_tmf_params,"OWNER_SIDE",[GVAR(side_enemy)]] call CFUNC(hashSet);
// _tmf_params = [_tmf_params,"TAKER_SIDE",[GVAR(side_own)]] call CFUNC(hashSet);
// _tmf_params = [_tmf_params,"TAKEN_CODE",""] call CFUNC(hashSet);
// _tmf_params = [_tmf_params,"LOST_CODE",""] call CFUNC(hashSet);
// _tmf_params = [_tmf_params,"SHARED_DIST",300] call CFUNC(hashSet);

OBJ = [_obj_params,"TAKEOVER",_tmf_params] call FFUNC(CreateMissionObject);